package nl.hva.three2learn.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import nl.hva.three2learn.authentication.Role;

import nl.hva.three2learn.authentication.Role;
import nl.hva.three2learn.authentication.UserAuthentication;

import org.codehaus.jackson.annotate.JsonIgnore;

@Table(name = "three2learn_user")
@Entity
public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8927607710416012468L;

	@Id
	@GeneratedValue
	@Column(name = "user_id")
	private long id;

	@Column(name = "password")
	@JsonIgnore
	private String password;

	@Column(name = "first_name")
	private String firstName;

	@Column(name = "last_name")
	private String lastName;

	@Column(name = "email")
	@JsonIgnore
	private String email;

	@Column(name = "phone_number")
	@JsonIgnore
	private String phoneNumber;

	@Column(name = "country")
	@JsonIgnore
	private String country;

	@Column(name = "city")
	@JsonIgnore
	private String city;

	@Column(name = "street")
	@JsonIgnore
	private String street;

	@Column(name = "house_number")
	@JsonIgnore
	private int houseNumber;

	@Column(name = "postal")
	@JsonIgnore
	private String postal;

	@Column(name = "is_active")
	@JsonIgnore
	private boolean isActive;

	@Column(name = "is_disabled")
	@JsonIgnore
	private boolean disabled;
	
	@Column(name="role") 
	@Enumerated(EnumType.STRING) 
	private Role role;
		
	/**
	 * Creates a user with everything set to default
	 * values except for the role. The role is set to {@link Role#USER}
	 */
	public User() {
		this.role = Role.USER;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFullName() {
		return firstName + " " + lastName;
	}
	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public int getHouseNumber() {
		return houseNumber;
	}

	public void setHouseNumber(int houseNumber) {
		this.houseNumber = houseNumber;
	}

	public String getPostal() {
		return postal;
	}

	public void setPostal(String postal) {
		this.postal = postal;
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}
}
